<?php 
$username = $_POST['username'];
$password = $_POST['password'];
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$idcard = $_POST['idcard'];
$param = array();
$link = mysql_connect("localhost", "root", "1234");
mysql_select_db("busticket", $link);
mysql_query("SET NAMES UTF8");
$query = "select * from member";
$result = mysql_query($query,$link);
$row = mysql_num_rows($result)+1;
while ($object = mysql_fetch_object($result)){
	if($object->username == $username){
		$param[] = "user";
	}
	if($object->idcard == $idcard){
		$param[] = "idc";
	}
	if($object->email == $email){
		$param[] = "em";
	}
}

if(count($param) != 0){
	$_param = join($param, "&");
	echo "<script>location.href='../view/register.php?$_param'</script>";
} else {
	mysql_query("insert into member values(null,'$name','$lastname','$username','$password','$idcard','$email');");
	header("Location:../view.index.php");
}

mysql_close($link);
?>